package com.wc.codeforces.总结题.Fibonacciness;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/5/4 17:37
 * @description
 * https://codeforces.com/contest/2060/problem/A
 */
public class Main {
    /**
     * 思路：
     * a[1] a[2] a[3] a[4] a[5]
     * a[3] = a[1] + a[2]
     * a[3] = a[4] - a[2]
     * a[3] = a[5] - a[4]
     * 能保证 a[3] 相等最多的, 也就是答案
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 10;
    static int[] a = new int[N], w = new int[N];

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            a[1] = sc.nextInt();
            a[2] = sc.nextInt();
            a[4] = sc.nextInt();
            a[5] = sc.nextInt();
            w[1] = a[1] + a[2];
            w[2] = a[4] - a[2];
            w[3] = a[5] - a[4];
            Arrays.sort(w, 1, 4);
            int res = -1;
            if (w[1] == w[2] && w[2] == w[3]) res = 3;
            if ((w[1] == w[2] && w[2] != w[3]) || (w[1] != w[2] && w[2] == w[3])) res = 2;
            if (w[1] != w[2] && w[2] != w[3]) res = 1;
            out.println(res);
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

